package hivMultiCompartment;

public class PortEntry extends FixedObject implements InputPort {
	
	//instance fields
	public boolean tCellEntry;
	public boolean bCellEntry;
	public boolean apcEntry;
	public boolean virusEntry;
	
	public PortEntry() {
		super ();
		initiatePort();
	}
	//overloading the constructor. only need the 2Dspace verison because we don't need ports for non-spatial organs
	public PortEntry (Organ2DSpace organ) {
		super(organ);
		initiatePort();
	}
	private void initiatePort(){
		tCellEntry = false;
		bCellEntry = false;
		virusEntry = false;
		apcEntry = false;
		setColor(GlobalConstants.colorPortEntry);
	}
	
	@Override
	public boolean isTCellEntry() {
		return tCellEntry;
	}

	@Override
	public boolean isBCellEntry() {
		return bCellEntry;
	}

	@Override
	public boolean isAPCEntry() {
		return apcEntry;
	}

	@Override
	public boolean isVirusEntry() {
		return virusEntry;
	}

	@Override
	public void setEntry(boolean st, boolean sb, boolean sa, boolean sv) {
		tCellEntry = st;
		bCellEntry = sb;
		apcEntry = sa;
		virusEntry = sv;
	}
	/**
	 * test whether this port is valid entry for the given object
	 * @return
	 */
	public boolean isEntry(AgentOnGrid agt) {
		boolean result = false;
		if (Virus.class.isInstance(agt)) {
			 if(virusEntry) {
				result = true;
			}
		}
		else if (TCell.class.isInstance(agt)) {
			 if(tCellEntry) {
				result = true;
			}
		}
		else if (BCell.class.isInstance(agt)) {
			 if(bCellEntry) {
				result = true;
			}
		}
		else if (APCell.class.isInstance(agt)) {
			if(apcEntry) {
				result = true;
			}
		}
		else {
			System.out.println("Port unable to determine accessablility of this agent: " + agt.getClass().toString());
		}
		
		return result;	
	}

}
